<?php
    //Lay danh sach menu
    $content = array();
    $opt = array(
        'conditions' => array('MenuLink.menu_id' => 'main-menu','MenuLink.enabled' => 1),    
        'find' => 'threaded',
        'order' => array('MenuLink.rght' => 'asc')
    );
    $content = $this->String->get_data('Menu','MenuLink',$opt); 
    $class = 'item';
?>
<nav class="navbar navbar-default" role="navigation">
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
            <?php if(!empty($content)):?>
                <li class="active"><a href="/" class="nav-home"><i class="icon-cus-home"></i></a></li>
                <?php foreach($content as $key => $values):?>
                    <?php  if(count($values['children']) > 0):?>
                        <li class="dropdown item_<?php echo $values['MenuLink']['id']?>">
                            <a href="<?php echo $values['MenuLink']['path'];?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $values['MenuLink']['title'];?></a>
                            <ul class="dropdown-menu sub-menu-cus" role="menu">
                                <?php foreach($values['children'] as $childKey => $childValues):?>
                                    <?php  if(count($childValues['children']) > 0):?> 
                                        <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $childValues['MenuLink']['title'];?></a>
                                            <ul class="sub-menu-cus-child">
                                                <?php foreach($childValues['children'] as $subKey => $subValues):?>
                                                    <li class="sub-mn-item"><a href="<?php echo $subValues['MenuLink']['path'];?>"><?php echo $subValues['MenuLink']['title'];?></a></li>
                                                <?php endforeach;?>
                                            </ul>
                                        </li>
                                        <?php else:?>
                                        <li class="item"><a href="<?php echo $childValues['MenuLink']['path'];?>"><?php echo $childValues['MenuLink']['title'];?></a></li>
                                        <?php endif;?>
                                    <?php endforeach;?>
                            </ul>
                        </li>
                        <?php else:?>
                        <li class="item"><a href="<?php echo $values['MenuLink']['path'];?>"><?php echo $values['MenuLink']['title'];?></a></li>
                        <?php endif;?>
                    <?php endforeach;?>
                <?php endif;?>
        </ul>
    </div><!-- /.navbar-collapse -->
</nav>